import 'package:flutter/material.dart';

import 'package:get/get.dart';

import '../../../../components/bottomAppBar/bottom_app_bar_2.dart';
import '../controllers/bottom2_controller.dart';

class Bottom2View extends GetView<Bottom2Controller> {
  const Bottom2View({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey[200],
      appBar: AppBar(
        title: const Text('山峦起伏菜单'),
        centerTitle: true,
      ),
      body: Stack(
        children: [content(), bottomBar()],
      ),
    );
  }

  Widget content() {
    return Positioned.fill(
        child: Container(
      alignment: Alignment.center,
      child: Text(
        controller.pageIndex.toString(),
        style: TextStyle(
          color: Colors.grey[400],
          fontSize: 80,
        ),
      ),
    ));
  }

  Widget bottomBar() {
    return Positioned(
      left: 0,
      right: 0,
      bottom: 0,
      child: BottomAppBar2(
        tabIconList: controller.tabIconsList,
        changeIndex: (index) => onClickBottomBar(index),
      ),
    );
  }

  void onClickBottomBar(int index) {
    controller.setPageIndex(index);
  }
}
